﻿Imports System.Data
Imports System.Data.OleDb

Partial Class PlacesUploadPictures
    Inherits System.Web.UI.Page
    'modify to insert pictures by album
    Protected Sub btnSubmit_Click(sender As Object, e As System.EventArgs) Handles btnSubmit.Click
        Dim myGUID As System.Guid
        myGUID = Guid.NewGuid()
        Dim newFileName = myGUID.ToString() + ".jpg"

        If A_Image.HasFile Then
            Dim picLocationOnServerHardDisk = Request.MapPath("pix") & "/" & newFileName
            A_Image.SaveAs(picLocationOnServerHardDisk)
        End If

        Dim oleDbConn As New OleDb.OleDbConnection(ConfigurationManager.ConnectionStrings("myFirstDatabase").ConnectionString)
        Dim SqlString As String = "Insert into tblplaces(AlbumID,FileUpload1,FileUpload2,FileUpload3,FileUpload4,FileUpload5) Values (@f1,@f2,@f3,@f4,@f5,@f6)"
        Dim cmd As OleDbCommand = New OleDbCommand(SqlString, oleDbConn)
        Dim SubmittedDate As DateTime = Now()
        Dim format As String = "ddd MMM yyyy"
        cmd.CommandType = CommandType.Text
        cmd.Parameters.AddWithValue("@f1", "pix/" & A_Image.FileName)
        cmd.Parameters.AddWithValue("@f2", "pix/" & A_Image.FileName)
        cmd.Parameters.AddWithValue("@f3", "pix/" & A_Image.FileName)
        cmd.Parameters.AddWithValue("@f4", "pix/" & A_Image.FileName)
        cmd.Parameters.AddWithValue("@f5", "pix/" & A_Image.FileName)
        cmd.Parameters.AddWithValue("@f6", txtAlDesc.Text)
        oleDbConn.Open()
        cmd.ExecuteNonQuery()
        Response.Redirect("PlacesCreateAlbumSuccess.aspx")


        Response.Redirect("PlacesUploadPicturesSuccess.aspx")
    End Sub
End Class
